* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #6a4c93;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

#game-container {
    width: 100%;
    max-width: 500px;
    height: 100vh;
    max-height: 900px;
    background-color: #4a3b6b;
    display: flex;
    flex-direction: column;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

#game-header {
    background-color: #3a2e53;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
}

#player-info {
    display: flex;
    align-items: center;
}

#player-avatar {
    width: 50px;
    height: 50px;
    background-color: #f8c0c8;
    border-radius: 10px;
    margin-right: 10px;
    background-image: url('../assets/avatar.png');
    background-size: cover;
}

#hearts, #stars {
    margin-left: 10px;
}

#level-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Reposition the instructions link below level selector */
#instructions {
    margin-top: 10px;
    text-align: center;
}

#instructions a {
    color: white;
    text-decoration: none;
    font-size: 0.9em;
    transition: all 0.2s;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 5px 10px;
    border-radius: 4px;
    display: inline-block;
}

#instructions a:hover {
    color: yellow;
    background-color: rgba(0, 0, 0, 0.7);
}

#game-board {
    flex-grow: 1;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(7, 1fr);
    gap: 2px;
    padding: 10px;
    background-color: #5a4580;
    position: relative; /* 添加这行 */
}

.cell {
    background-color: #4a3b6b;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.cell:hover {
    transform: scale(1.05);
}

.monster {
    width: 90%;
    height: 90%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.monster-blue {
    background-image: url('../assets/monster-blue.png');
}

.monster-pink {
    background-image: url('../assets/monster-pink.png');
}

.monster-red {
    background-image: url('../assets/monster-red.png');
}

.monster-green {
    background-image: url('../assets/monster-green.png');
}

.monster-yellow {
    background-image: url('../assets/monster-yellow.png');
}

.box {
    background-image: url('../assets/box.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    width: 90%;
    height: 90%;
}

.box-value {
    position: absolute;
    bottom: 0;
    right: 5px;
    color: white;
    font-weight: bold;
    font-size: 1.5em;
    text-shadow: 1px 1px 2px black;
}

.boss {
    background-image: url('../assets/boss.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    width: 90%;
    height: 90%;
}

.boss-health {
    position: absolute;
    bottom: 10px;
    right: 5px;
    color: white;
    font-weight: bold;
    font-size: 1em;
    text-shadow: 1px 1px 2px black;
    background-color: rgba(255, 0, 0, 0.5);
    padding: 0 5px;
    border-radius: 5px;
}

.gem {
    background-image: url('../assets/gem.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    width: 90%;
    height: 90%;
}

.tree {
    background-image: url('../assets/tree.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    width: 90%;
    height: 90%;
}

.wood {
    background-image: url('../assets/wood.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    width: 90%;
    height: 90%;
}

.selected {
    border: 2px solid yellow;
    transform: scale(1.1);
    z-index: 10;
}

.path {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px dashed yellow;
    z-index: 5;
}

#game-footer {
    background-color: #3a2e53;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#character-selection {
    display: flex;
    gap: 10px;
}

.character {
    width: 50px;
    height: 50px;
    background-color: #f8c0c8;
    border-radius: 10px;
    background-size: cover;
}

.character.active {
    border: 2px solid yellow;
}

.character.locked {
    background-color: #888;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.7em;
    text-align: center;
}

#attack-button {
    width: 80px;
    height: 80px;
    background-color: #f8c0c8;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 1.5em;
    cursor: pointer;
    transition: all 0.2s;
}

#attack-button:hover {
    transform: scale(1.1);
}

/* Add styling for the undo button */
#undo-button {
    width: 80px;
    height: 80px;
    background-color: #c0f8ee;  /* Slightly different color than attack button */
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 1.5em;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 10px;  /* Add some space between the buttons */
}

#undo-button:hover {
    transform: scale(1.1);
}

#attack-power {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-weight: bold;
    z-index: 100;
}

#monster-count {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-weight: bold;
}

.game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 2em;
    z-index: 100;
}

.game-over button {
    margin-top: 20px;
    padding: 10px 20px;
    background-color: #f8c0c8;
    border: none;
    border-radius: 5px;
    font-size: 0.5em;
    cursor: pointer;
}

.connection-line {
    position: absolute;
    background-color: yellow;
    z-index: 5;
    transform-origin: 0 50%;
}

/* 添加箭头样式 */
.connection-arrow {
    position: absolute;
    width: 20px;
    height: 16px;
    background-color: rgba(255, 255, 0, 0.8);
    clip-path: polygon(0% 20%, 60% 20%, 60% 0%, 100% 50%, 60% 100%, 60% 80%, 0% 80%);
    z-index: 15;
    pointer-events: none;
    transform-origin: left center;
}

.player {
    background-image: url('../assets/player.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    width: 90%;
    height: 90%;
    z-index: 10;
}

/* 元素出现动画 */
@keyframes appear {
    from {
        transform: scale(0.5);
        opacity: 0.5;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* 为动画添加硬件加速 */
.element-appear {
    animation: appear 0.3s ease-out;
    will-change: transform, opacity;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* 禁用交互样式 */
.disabled {
    pointer-events: none;
    opacity: 0.95;
}

/* 禁用交互样式 - 调整透明度为更温和的值，不使界面变暗 */
.disabled {
    pointer-events: none;
    opacity: 0.95;  /* 改为更高的透明度，避免画面变黑 */
}

/* 添加平滑的过渡效果 */
.cell > div {
    transition: opacity 0.2s ease-out;
}

/* 禁用交互样式 */
.disabled {
    pointer-events: none;
    opacity: 0.95;
}

#target {
    margin-top: 5px;
    font-size: 0.9em;
    text-align: right;
}

.target-item {
    margin-top: 2px;
    white-space: nowrap;
}

.target-completed {
    color: #5df15d;
}

#level-selector {
    position: absolute;
    left: 20px;
    top: 20px;
    z-index: 50;
}

#level-select {
    padding: 8px 12px;
    font-size: 16px;
    border: 2px solid #4a90e2;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    min-width: 150px;
    margin-top:50px;
}

#level-select:hover {
    border-color: #357abd;
}

#level-select:focus {
    outline: none;
    border-color: #357abd;
    box-shadow: 0 0 5px rgba(74, 144, 226, 0.5);
}